package com.example.common.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.Set;

/**
 * ${DESCRIPTION}
 */


public class CP_RedisUtils {

    @Autowired
    RedisTemplate redisTemplate;

    @SuppressWarnings("unchecked")
    public void setObject(String key,Object object){
        redisTemplate.opsForValue().set(key,object);
    }

    public Object getObject(String key){
        return redisTemplate.opsForValue().get(key);
    }

    @SuppressWarnings("unchecked")
    public Set<String>  getAllKeyByPattern(String pattern ){
        return redisTemplate.keys(pattern+"*");
    }

    @SuppressWarnings("unchecked")
    public boolean removeObject(String key){
        return redisTemplate.delete(key);
    }
}
